package com.test.down.adapter.holders

import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.download.manager.M3u8DownLoadService
import com.test.down.beans.BaseBean
import com.test.down.beans.LiveBean
import com.test.down.R
import com.test.down.adapter.BaseHolders
import com.test.down.utils.DownLoadInfouTIL

class LiveHolders(val context:Context,val contentView:View) : BaseHolders(contentView){

    override fun setItemData(item: BaseBean, position:Int){
        if(item is LiveBean) {
            Glide.with(context).load(item.liveCover).into(contentView.findViewById<ImageView>(R.id.iv_cover))
            contentView.findViewById<TextView>(R.id.tv_title).text = item.title
            contentView.findViewById<Button>(R.id.btn_load).setOnClickListener {
                DownLoadInfouTIL.getInstance().insetItemToDownLoadList(item)
                val intent=Intent(context,M3u8DownLoadService::class.java)
                intent.putExtra(M3u8DownLoadService.URL_VALE,item.playUrl)
                context.startService(intent)
            }
        }
    }

}